package graphics.objects;
import org.lwjgl.opengl.GL11;

import graphics.system.Color;
import graphics.system.GLTools;
import graphics.system.Texture;
import graphics.system.TextureContainer;
import tools.Floatmath;
import tools.Point;
public class GAtmosphereLight extends GLight {
	private float radius;
	private Texture tex;
	public GAtmosphereLight(Point pos, float radius, Color color) {
		super(pos, radius, 0, color, false);
		this.radius = radius;
		this.tex = TextureContainer.getTexture("lightmap");
	}
	public float getRadius() {
		return radius * Floatmath.max(node.scale.x, node.scale.y);
	}
	public void drawGlow() {
		GL11.glPushMatrix();
		node.setUpGl();
		GLTools.drawTexRect(Point.ZERO, radius * 2, radius * 2, 0, tex.getTexID(), color);
		GL11.glPopMatrix();
	}
	public void drawDebug() {
		GL11.glEnable(GL11.GL_LINE_STIPPLE);
		GL11.glLineStipple(1, (short) 0xFF);
		GL11.glPushMatrix();
		node.setUpGl();
		GLTools.drawCircleLine(Point.ZERO, radius, 0, Color.blue, false);
		GL11.glPopMatrix();
		GL11.glDisable(GL11.GL_LINE_STIPPLE);
	}
	public String toFileString() {
		String s = super.toFileString();
		s = s + "/" + radius;
		return s;
	}
	public int fromFileString(String s) {
		int off = super.fromFileString(s);
		String l[] = s.split("/");
		radius = Float.valueOf(l[off + 1]);
		node.boundingrad = radius;
		return off + 1;
	}
}
